﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace JMcms.Web.Plugin.Job.BLL
{
   public class job
    {
        private readonly JMcms.Model.sysconfig sysConfig = new JMcms.BLL.sysconfig().loadConfig();//获得系统配置信息
        private readonly JMcms.Web.Plugin.Job.DAL.job dal;
        public job()
        {
            this.dal = new JMcms.Web.Plugin.Job.DAL.job(sysConfig.sysdatabaseprefix);
        }
        public bool Exists(int id)
        {
            return this.dal.Exists(id);
        }
        public int Add(JMcms.Web.Plugin.Job.Model.job model)
        {
            return this.dal.Add(model);
        }
        public bool Update(JMcms.Web.Plugin.Job.Model.job model)
        {
            return this.dal.Update(model);
        }
        public bool UpdateField(int id, string strValue)
        {
            return this.dal.UpdateField(id, strValue);
        }
        public bool Delete(int id)
        {
            bool flag = this.dal.Delete(id);
            bool flag2 = flag;
            if (flag2)
            {
                JMcms.Web.Plugin.Job.BLL.job_apply job_apply = new JMcms.Web.Plugin.Job.BLL.job_apply();
                job_apply.Deletes(id);
            }
            return flag;
        }
        public JMcms.Web.Plugin.Job.Model.job GetModel(int id)
        {
            return this.dal.GetModel(id);
        }
        public string GetTitle(int id)
        {
            JMcms.Web.Plugin.Job.Model.job job = new JMcms.Web.Plugin.Job.Model.job();
            job = this.GetModel(id);
            return job.title;
        }
        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }
        public List<JMcms.Web.Plugin.Job.Model.job> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }
        public List<JMcms.Web.Plugin.Job.Model.job> DataTableToList(DataTable dt)
        {
            List<JMcms.Web.Plugin.Job.Model.job> list = new List<JMcms.Web.Plugin.Job.Model.job>();
            int count = dt.Rows.Count;
            bool flag = count > 0;
            if (flag)
            {
                for (int i = 0; i < count; i++)
                {
                    JMcms.Web.Plugin.Job.Model.job job = this.dal.DataRowToModel(dt.Rows[i]);
                    bool flag2 = job != null;
                    if (flag2)
                    {
                        list.Add(job);
                    }
                }
            }
            return list;
        }
        public DataSet GetAllList()
        {
            return this.GetList("");
        }
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return this.dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }
    }
}
